package cn.bugstack.mybatis.mapping;

import cn.bugstack.mybatis.session.Configuration;

import java.util.List;

public class BoundSql {

    private Configuration configuration;

    private String parameterType;


    /**
     * #{id, javaType=Integer, jdbcType=NUMERIC}
     */
    private List<ParameterMapping> parameterMappings;
    private String resultType;
    private String sql;

    private Object parameterObject;


    public Object getParameterObject() {
        return parameterObject;
    }

    private BoundSql() {

    }


    public String getParameterType() {
        return parameterType;
    }

    public void setParameterType(String parameterType) {
        this.parameterType = parameterType;
    }

    public List<ParameterMapping> getParameterMappings() {
        return parameterMappings;
    }

    public void setParameterMappings(List<ParameterMapping> parameterMappings) {
        this.parameterMappings = parameterMappings;
    }

    public String getResultType() {
        return resultType;
    }

    public void setResultType(String resultType) {
        this.resultType = resultType;
    }

    public String getSql() {
        return sql;
    }

    public void setSql(String sql) {
        this.sql = sql;
    }


    public static class Builder {
        private BoundSql boundSql = new BoundSql();

        public Builder configuration(Configuration configuration) {
            boundSql.configuration = configuration;
            return this;
        }

        public Builder parameterType(String parameterType) {
            boundSql.parameterType = parameterType;
            return this;
        }
        public Builder parameterMapping(List<ParameterMapping> parameterMapping) {
            boundSql.parameterMappings = parameterMapping;
            return this;
        }
        public Builder parameterObject(Object parameterObject) {
            boundSql.parameterObject = parameterObject;
            return this;
        }

        public Builder resultType(String resultType) {
            boundSql.resultType = resultType;
            return this;
        }
        public Builder sql(String sql) {
            boundSql.sql = sql;
            return this;
        }
        public BoundSql build() {
            return boundSql;
        }
    }

}
